class smx_base {
  require smx_os

  $base_service_packages = [
    'gearmand',
    'rubygems',
    'bind-utils',
  ]

  package { $base_service_packages :
    ensure => installed,
  }

  exec { 'install-fakes3':
    unless  => '/usr/bin/which fakes3',
    path    => ["/sbin", "/usr/sbin", "/usr/local/sbin", "/usr/local/bin", "/usr/bin", "/bin"],
    command => '/usr/bin/gem install fakes3 --verbose --version 0.2.4 --no-rdoc --no-ri --source https://gems.ruby-china.org/',
    timeout => 600,
    require => Package['rubygems'],
  }
  if $operatingsystemrelease =~ /^6\./ {
    file { '/etc/init.d/fakes3':
      ensure  => file,
      mode    => 755, group  => root, owner  => root,
      source  => "puppet:///modules/smx_base/fakes3_6",
      require => Exec['install-fakes3'],
    }
  }
  elsif $operatingsystemrelease =~ /^7\./ {
    file { '/etc/init.d/fakes3':
      ensure  => file,
      mode    => 755, group  => root, owner  => root,
      source  => "puppet:///modules/smx_base/fakes3",
      require => Exec['install-fakes3'],
    }
  }
  else {
    notify { "Some other operating system detected": }
  }
  service { 'fakes3':
    ensure    => running,
    enable    => true,
    path      => "/etc/init.d",
    start     => "/etc/init.d/fakes3 start",
    stop      => "/etc/init.d/fakes3 stop",
    subscribe => File['/etc/init.d/fakes3'],
  }

  service { 'gearmand':
    enable  => true,
    ensure  => running,
    require => Package['gearmand'],
  }

}
